package com.anti.modular.bus.housebilldetail.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.housebilldetail.param.HouseBillDetailParam;
import com.anti.modular.bus.housebilldetail.service.HouseBillDetailService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 账单详情控制器
 *
 * @author anti
 * @date 2021-05-07 09:59:49
 */
@RestController
@RequestMapping("houseBillDetail")
public class HouseBillDetailController {

    @Resource
    private HouseBillDetailService houseBillDetailService;

    /**
     * 查询账单详情
     *
     * @author anti
     * @date 2021-05-07 09:59:49
     */
    @GetMapping("page")
    @BusinessLog(title = "账单详情_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result page(PageParam pageParam, HouseBillDetailParam houseBillDetailParam) {
        return Result.data(houseBillDetailService.page(pageParam,houseBillDetailParam));
    }

    /**
     * 添加账单详情
     *
     * @author anti
     * @date 2021-05-07 09:59:49
     */
    @PostMapping("add")
    @BusinessLog(title = "账单详情_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(HouseBillDetailParam.add.class) HouseBillDetailParam houseBillDetailParam) {
            houseBillDetailService.add(houseBillDetailParam);
        return Result.success("新增成功");
    }

    /**
     * 删除账单详情
     *
     * @author anti
     * @date 2021-05-07 09:59:49
     */
    @PostMapping("delete")
    public Result delete(@RequestBody @Validated(HouseBillDetailParam.delete.class) HouseBillDetailParam houseBillDetailParam) {
            houseBillDetailService.delete(houseBillDetailParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑账单详情
     *
     * @author anti
     * @date 2021-05-07 09:59:49
     */
    @PostMapping("edit")
    public Result edit(@RequestBody @Validated(HouseBillDetailParam.edit.class) HouseBillDetailParam houseBillDetailParam) {
            houseBillDetailService.edit(houseBillDetailParam);
        return Result.success("修改成功");
    }

    /**
     * 查看账单详情
     *
     * @author anti
     * @date 2021-05-07 09:59:49
     */
    @GetMapping("detail")
    public Result detail(@Validated(HouseBillDetailParam.detail.class) HouseBillDetailParam houseBillDetailParam) {
        return Result.data(houseBillDetailService.detail(houseBillDetailParam));
    }

    /**
     * 查看账单详情
     *
     * @author anti
     * @date 2021-05-07 09:59:49
     */
    @GetMapping("detailByBillId/{billId}/{type}")
    public Result detailByBillId(@PathVariable(name = "billId") Long billId,@PathVariable(name = "type") int type) {
        return Result.data(houseBillDetailService.detailByBillId(billId,type));
    }

    /**
     * 账单详情列表
     *
     * @author anti
     * @date 2021-05-07 09:59:49
     */
    @GetMapping("list")
    public Result list(HouseBillDetailParam houseBillDetailParam) {
        return Result.data(houseBillDetailService.list(houseBillDetailParam));
    }

}
